<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
</head>
<body>
	<form action="toinsert" method="post" id="fm" >
		订单编号:<input type="text" name="id" >
		下单时间:<input type="date" name="orderDate" pattern="yyyy-MM-dd"><br>
		订货人:<input type="text" name="name" >
		金额:<input type="text" name="price" ><br>
		制单人:<input type="text" name="prepared" >
		交货方式:<input type="text" name="type" ><br>
		交货地点<input type="text" name="add" >
		<input type="button" value="增加" onclick="zj()"> 
		<table>
			<thead>
				<tr>
					<td>行号</td>			
					<td>商品编号</td>			
					<td>商品名称</td>
					<td>型号</td>
					<td>单价</td>
					<td>数量</td>
					<td>金额</td>
					<td>备注</td>				
				</tr>
			</thead>
			<tbody>
				
			</tbody>
		</table>
		<input type="button" value="提交" onclick="tj()" >
		<input type="reset" value="重置" >
	</form>
	<script type="text/javascript">
		var count=0;
		function zj(){
			$("tbody").append('<tr class="cls"><td><input type="text" name="details['+count+'].line" ></td><td><input type="text" name="details['+count+'].goodNum" ></td><td><input type="text" name="details['+count+'].goodName" ></td><td><input type="text" name="details['+count+'].goodType" ></td><td><input type="text" name="details['+count+'].goodPrice" ></td><td><input type="text" name="details['+count+'].goodCount" ></td><td><input type="text" name="details['+count+'].goodsum" ></td><td><input type="text" name="details['+count+'].rmk" ></td></tr>');
			count++;
		}
		function tj(){
			var num = $(".cls").length;
			if (num>0) {
				$("#fm").submit();
			}else {
				alert("至少添加一条明细");
			}
		}
	</script>
</body>
</html>